package mqs

import (
	"blogcenter/internal/config"
	"blogcenter/internal/svc"
	"context"
	"time"

	"github.com/zeromicro/go-queue/kq"
	"github.com/zeromicro/go-zero/core/service"
)

func StartConsumers(c config.Config, ctx context.Context, svcCtx *svc.ServiceContext) []service.Service {
	commentConsumer := NewCommentConsumer(
		ctx,
		svcCtx.CommentModel,
		svcCtx.CommentBatcher,
	)

	return []service.Service{
		kq.MustNewQueue(
			c.Kafka.Consumer,
			commentConsumer,
			kq.WithQueueCapacity(1000),
			kq.WithMaxWait(time.Second),
		),
	}
}
